//
//  TapEnglishViewController.m
//  TapEnglish
//
//  Created by 이선동 on 11. 4. 13..
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "TapEnglishViewController.h"
#import "Head.h"
#import "Stomach.h"
#import "Arm.h"
#import "Hand.h"
#import "Leg.h"
#import "Foot.h"
#import "Body.h"

@implementation TapEnglishViewController

- (void)dealloc
{

    [super dealloc];
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle


// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
{
    [super viewDidLoad];
    
    vocaGroup = [[NSDictionary alloc] initWithDictionary:[self createData]];
}

- (void)viewWillAppear:(BOOL)animated {
    [self soundPlay:@"Touch Korean.aiff"];    
}

- (void)viewDidUnload
{

    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

- (IBAction)goHead:(id)sender {
    Head *newViewController = [[Head alloc] initWithNibName:@"Head" bundle:nil];
    newViewController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
    [self presentModalViewController:newViewController animated:YES];
    [newViewController release];
}

- (IBAction)goStomach:(id)sender {
    Stomach *newViewController = [[Stomach alloc] initWithNibName:@"Stomach" bundle:nil];
    newViewController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
    [self presentModalViewController:newViewController animated:YES];
    [newViewController release];
}

- (IBAction)goArm:(id)sender {
    Arm *newViewController = [[Arm alloc] initWithNibName:@"Arm" bundle:nil];
    newViewController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
    [self presentModalViewController:newViewController animated:YES];
    [newViewController release];
}

- (IBAction)goHand:(id)sender {
    Hand *newViewController = [[Hand alloc] initWithNibName:@"Hand" bundle:nil];
    newViewController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
    [self presentModalViewController:newViewController animated:YES];
    [newViewController release];
}

- (IBAction)goLeg:(id)sender {
    Leg *newViewController = [[Leg alloc] initWithNibName:@"Leg" bundle:nil];
    newViewController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
    [self presentModalViewController:newViewController animated:YES];
    [newViewController release];
}

- (IBAction)goFoot:(id)sender {
    Foot *newViewController = [[Foot alloc] initWithNibName:@"Foot" bundle:nil];
    newViewController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
    [self presentModalViewController:newViewController animated:YES];
    [newViewController release];
}

- (IBAction)goBody:(id)sender {
    Body *newViewController = [[Body alloc] initWithNibName:@"Body" bundle:nil];
    newViewController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
    [self presentModalViewController:newViewController animated:YES];
    [newViewController release];
}


- (NSDictionary *) createData {
    
	NSArray *body_voca = [[NSArray alloc] initWithObjects: 
                           @"hair", 
                           @"eyebrow", 
                           @"ear", 
                           @"cheek", 
                           @"chin", 
                           @"finger", 
                           @"wrist", 
                           @"elbow", 
                           @"thigh", 
                           @"knee", 
                           @"head", 
                           @"eye", 
                           @"nose", 
                           @"mouth", 
                           @"neck", 
                           @"shoulder", 
                           @"chest", 
                           @"arm", 
                           @"stomach", 
                           @"belly button", 
                           @"hand", 
                           @"finger nail", 
                           @"leg", 
                           @"foot", 
                           @"toe",  
                           nil];
    
    
    NSDictionary *returnDictionary = [NSDictionary dictionaryWithObjectsAndKeys:
                                      body_voca, @"body_voca", nil];
    [body_voca release];
    
	return returnDictionary;
}

SystemSoundID soundID;

CFURLRef baseURL;

- (void) soundPlay:(NSString *)audioName{
	NSString *sndPath = [[NSBundle mainBundle] pathForResource:audioName ofType:nil];
	baseURL = (CFURLRef)[[NSURL alloc] initFileURLWithPath:sndPath];
	AudioServicesCreateSystemSoundID(baseURL, &soundID);
	AudioServicesPlaySystemSound(soundID);
}

@end
